package collision;

import java.awt.Image;
import java.awt.Rectangle;

import java.util.Random;
import javax.swing.ImageIcon;
        


public class Zombie {

    private String craft = "/Sprites/vaporeon_walk.gif";

    private int x;
    private int y;
    private int width;
    private int height;
    private boolean visible;
    private int imagex;
    private int imagew;
    private Image image;
    
    private int WALKDELAY = 500;

    private boolean move;
    private int hp;
    private int dmg;
    
    
    public Zombie(int x) {
        Random rand = new Random();
        Table table = new Table();
        ImageIcon ii = new ImageIcon(this.getClass().getResource(craft));
        image = ii.getImage();
        width = 37;
        height = image.getHeight(null);
        visible = true;

        this.x = x;
        this.y = table.insertY(rand.nextInt(table.getYEND() - table.getYBEGIN()) + table.getYBEGIN());
        if( this.y == -1){
            this.y = table.insertY(table.getYBEGIN() + 1);
        }
        imagex = 0;
        imagew = 37;
        hp = 10;
        dmg = 3;
        
        move = true;
        
    }

    public int getImagew() {
        return imagew;
    }

    public int getImagex() {
        return imagex;
    }
    
    public boolean move(int i) {
        Table table = new Table();

        if( i% WALKDELAY == 0)
            if(imagex != 2*imagew)
                imagex += imagew;
            else imagex = 0;
        
        if(move == false)
            return true;
        
        if (x < table.getXBEGIN())
        {
            visible = false;
            return false;
        }
        else{
            x -= 1;
            return true;
        }
    }

     public int getDmg() {
        return dmg;
    }

    public void setDmg(int dmg) {
        this.dmg = dmg;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }
    
    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setMove(boolean move){
        this.move = move;
    }
    public boolean isVisible() {
        return visible;
    }

    public void setVisible(Boolean visible) {
        this.visible = visible;
    }

    public Image getImage() {
        return image;
    }

    public Rectangle getBounds() {
        return new Rectangle(x, y, width, height);
    }
}